package com.qijia.common.listener;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler;

public class LogoutHandler extends SecurityContextLogoutHandler {
	private final static transient Log	logger	= LogFactory
														.getLog(LogoutHandler.class);

	@Override
	public void logout(HttpServletRequest request,
			HttpServletResponse response, Authentication authentication) {
		logger.info("processing logout ...");
		// set a flag to indicate Auditer this is a logout event
		request.getSession().setAttribute("IS_LOGOUT", "true");

		super.logout(request, response, authentication);

		//退出系统日志
		if(authentication!=null){
			//AppAuditHelper.getInstance().doAuditAction(AppAuditHelper.ACTION_LOGOUT, null, AppAuditHelper.RESULT_SUCCESS, RequestUtil.getRemoteIP(request), authentication.getName(), StoreUtil.getCurrentStoreId(request));
		}
	}
}